package Libs.Utils.Strings
{
	public const LastIndexOfAny:Function = function( source:String, anyOf:Array, startIndex:int = 0x7FFFFFFF, count:uint = 0x7FFFFFFF ):int 
    {
        var i:int;
        var index:int ;
        if( !anyOf || source == null || source.length == 0 )
        {
            return - 1;
        }
        if ( startIndex > source.length )
        {
            startIndex = source.length ;
        }
        else if( startIndex < 0 )
        {
            return - 1 ;
        }
        var endIndex:int = startIndex - count + 1 ;
        if ( endIndex < 0 )
        {
            endIndex = 0 ;
        }
        source = source.slice( endIndex, startIndex + 1 ) ;
        var len:uint = anyOf.length ;
        for ( i = 0 ; i < len ; i++ )
        {
            index = source.lastIndexOf( anyOf[i], startIndex ) ;
            if (index > - 1) 
            {
                return index + endIndex;
            }
        }
        
        return - 1 ;
    };
}